<!DOCTYPE html>  
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN"> 
<head> 
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>会员规则</title>
	<!-- 常规css -->
    <link th:href="@{bootstrap/css/bootstrap.min.css}" rel="stylesheet" />
    <link th:href="@{font-awesome/css/font-awesome.min.css}" rel="stylesheet" />
    <!-- 项目css -->
    <link th:href="@{css/layout.css}" rel="stylesheet" />
</head> 
<body>
	<!-- 侧边导航栏 -->
	<div th:replace="aframe::sideNavigation"></div>
	
	<!-- 主页面 -->
	<div class="content" style="padding:0">
		<!-- 顶部导航栏 -->
		<div th:replace="aframe::topNavigation"></div>
		<!-- 内容 -->

		<!-- 标签页内容 -->
		<!--	拍卖	-->
		<div role="tabpanel" class="tab-pane active" style="margin-top:20px">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4>编辑会员规则&nbsp;&nbsp;</h4>
				</div>
				<div class="panel-body">
					<div id="wang_toolbar" class="toolbar">
					</div>
					<div style="padding: 3px 0; color: #ccc"></div>
					<div id="wang_text" class="text" style="height: 600px">
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" id="textButton">确认修改</button>
				</div>
			</div>
		</div>
	</div>
		<!-- end 内容 -->
	<!-- end 主页面 -->



	<!-- 模态框: 修改密码 -->
	<div th:replace="aframe::modifyPwd"></div>


<!-- 常规js -->
<script th:src="@{js/jquery-3.4.1.min.js}"></script>
<script th:src="@{bootstrap/js/bootstrap.min.js}"></script>
<!-- 模板js -->
<script th:replace="aframe::js-highlight"></script>
<!-- 项目js -->
<script th:src="@{js/md5.js}"></script>
<script th:src="@{js/setpwd.js}"></script>

<!-- 富文本编辑器js -->
<script type="text/javascript" th:src="@{wangEditor/release/wangEditor.min.js}"></script>
<!-- 页面js -->
<script type="text/javascript" th:inline="javascript">
	var E = window.wangEditor;
	var editor = new E('#wang_toolbar','#wang_text');
	editor.customConfig.zIndex = 100;
	editor.customConfig.menus = [
		'head',  // 标题
		'bold',  // 粗体
		'fontSize',  // 字号
		'fontName',  // 字体
		'italic',  // 斜体
		'underline',  // 下划线
		'strikeThrough',  // 删除线
		'foreColor',  // 文字颜色
		'backColor',  // 背景颜色
		'link',  // 插入链接
		'list',  // 列表
		'justify',  // 对齐方式
		'quote',  // 引用
		'table',  // 表格
		'image',  // 插入图片
		'emoticon',  // 表情
		'undo',  // 撤销
		'redo'  // 重复
	];
	// 配置服务器端地址
	editor.customConfig.uploadImgServer = '/upload/picture';
	editor.customConfig.uploadImgMaxLength = 5;
	editor.customConfig.uploadFileName = 'file';
	editor.customConfig.customAlert = function () {
		alert('上传图片失败')
	}
	editor.create();
	var data = [[${data}]];
	editor.txt.html(data);
</script>

<script type="text/javascript">
	$("#textButton").click(function () {
		var text = editor.txt.html();
		var formdata = new FormData();
		formdata.append('ruleInfoText', text);
		formdata.append("ruleInfoId", 3);
		$.ajax({
			type: "POST",
			url:"rule/edit",
			data:formdata,	// 序列化表单值
			processData:false,
			contentType:false,
			error: function(request) {
				alert("未知错误！");
			},
			success: function(res) {
				if(res.code==0) {
					alert("修改会员规则成功！");
					window.location.reload();
				}else{
					alert(res.msg);
				}
			}
		});
	});
</script>

</body>
</html> 

